HackerRank The Coin Change Problem
解答
code: python
import math
import os
import random
import re
import sys
#
# Complete the 'getWays' function below.
#
# The function is expected to return a LONG_INTEGER.
# The function accepts following parameters:
# 1. INTEGER n
# 2. LONG_INTEGER_ARRAY c
#
def getWays(n, c):
# Write your code here
for i in range(len(c)):
# 2 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 # 5 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 2 # 3 1, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4 # 6 1, 0, 1, 1, 1, 2, 3, 2, 4, 4, 5 if __name__ == '__main__':
first_multiple_input = input().rstrip().split()
n = int(first_multiple_input0) m = int(first_multiple_input1) c = list(map(int, input().rstrip().split()))
# Print the number of ways of making change for 'n' units using coins having the values given by 'c'
ways = getWays(n, c)
fptr.write(str(ways) + '\n')
fptr.close()
テーマ
メモ
https://www.youtube.com/watch?v=sCIqBTHiQAE